<?php
include_once dirname(__FILE__)."/common/basic.php";
include_once dirname(__FILE__)."/common/WeixinMPAPI.php";

$mpapi = new WeixinMPAPI();

if($_GET[signature]){
	$mpapi->valid();
}
$log->debug("收到请求");
$post = $mpapi->read();
if($post){
	$keyword = trim($post->Content);
	if($keyword){
		$feeds = $func->search_resource($_GET[skey],null,null, 1, 5);
		if($feeds && count($feeds)>0){
			$content = "";
			foreach($feeds as $fid){
				$feed = $func->getFeedDetail($fid);
				if($feed){
					$content .=$feed[name]." ".$config[weburl]."/u.php?feed=".$fid."。";
				}
			}
			$mpapi->write($content, $post);
		}else{
			$mpapi->write("没有符合条件的资源，最新资源请点击".$config[weburl], $post);
		}
	}
}
?>